import { Controller, Get, Post, Body, Headers, Inject } from '@midwayjs/core'
import { MenusService } from '../service/menu.service.js'

@Controller('menus')
export class MenusController {
  @Inject()
  menusService: MenusService

  @Post('/insertMenu')
  async insertMenu(@Body() data: any) {
    return this.menusService.insertMany([data])
  }

  @Get('/findMenus')
  async findMenus(@Headers('user') user: any) {
    return this.menusService.find(user)
  }

  @Post('/updateMenu')
  async updateMenu(@Body() data: any) {
    return this.menusService.updateOne(data)
  }

  @Post('/deleteMenu')
  async deleteMenu(@Body() data: any) {
    return this.menusService.deleteOne(data)
  }
}
